﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DevelopTools.UI
{
    public class UIPanel : MonoBehaviour
    {
        public List<UIElement> ElementList;
        // Use this for initialization
        void Start()
        {
            Init();
        }
        private void Init()
        {
            //for (int i = 0; i < transform; i++)
            //{
	        
            //}
        }

        // Update is called once per frame
        void Update()
        {

        }
        /// <summary>
        /// 显示元素
        /// </summary>
        public void ShowUIElement()
        {
            for (int i = 0; i < ElementList.Count; i++)
            {
                ElementList[i].gameObject.SetActive(true);
            }
        }
        /// <summary>
        /// 显示元素
        /// </summary>
        /// <param name="index">元素的位置</param>
        public void ShowUIElement(int index)
        {
            if (index >= ElementList.Count)
            {
                return;
            }
            ElementList[index].gameObject.SetActive(true);
        }
        /// <summary>
        /// 显示元素
        /// </summary>
        /// <param name="indexs">存放相应的index位置数组</param>
        public void ShowUIElement(int[] indexs)
        {
            for (int i = 0; i < ElementList.Count; i++)
            {
                for (int j = 0; j < indexs.Length; j++)
                {
                    if (i == indexs[j])
                    {
                        ElementList[i].gameObject.SetActive(true);
                        continue;
                    }
                }
            }
        }
        /// <summary>
        /// 隐藏元素
        /// </summary>
        public void HideUIElement()
        {
            for (int i = 0; i < ElementList.Count; i++)
            {
                ElementList[i].gameObject.SetActive(false);
            }
        }
        /// <summary>
        /// 隐藏元素
        /// </summary>
        /// <param name="index">元素的位置</param>
        public void HideUIElement(int index)
        {
            if (index >= ElementList.Count)
            {
                ElementList[index].gameObject.SetActive(false);
            }
        }
        /// <summary>
        /// 隐藏元素
        /// </summary>
        /// <param name="indexs">存放相应的index位置数组</param>
        public void HideUIElement(int[] indexs)
        {
            for (int i = 0; i < ElementList.Count; i++)
            {
                for (int j = 0; j < indexs.Length; j++)
                {
                    if (i == indexs[j])
                    {
                        ElementList[i].gameObject.SetActive(false);
                        continue;
                    }
                }
            }
        }
    }
}